// store/index.js
import Vue from "vue";
import Vuex from "vuex";
import modules from "./modules";
Vue.use(Vuex);

const globalStore = {
    state: {
        token: "", // 用户凭证 Token
        indexNav: 0, // 菜单栏索引
    },
    mutations: {
        //统一设置state
        SET_STATE(state, data) {
            Object.assign(state, data);
        },

        SET_INDEX(state, index) {
            state.indexNav = index;
        },
    },
    actions: {},
    getters: {
        token: (state) => state.token,
        indexNav: (state) => state.indexNav,
    },
};

const store = new Vuex.Store({
    modules,
    ...globalStore,
});

export default store;
